package cn.mxlshy.springcloud.controller;

import cn.mxlshy.springcloud.service.PaymentService;
import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: 马晓亮
 * @date: 2020/8/10 16:08
 * @description:
 */
@RestController
@Slf4j
public class OrderController {
    @Resource
    private PaymentService paymentService;

    @GetMapping("/consumer/payment/hystrix/ok/{id}")
    public String paymentInfoOk(@PathVariable Integer id) {
        String result = paymentService.paymentInfoOk(id);
        log.info("========result:"+result+"========");
        return result;
    }
    @GetMapping("/consumer/payment/hystrix/timeout/{id}")
    public String paymentInfoTimeout(@PathVariable Integer id) {
        String result = paymentService.paymentInfoTimeout(id);
        return result;
    }

    /**
     * 下面是全局fallback
     */

    public String paymentGlobalFallbackMethod() {
        return "Global异常信息处理，请稍后再试，o(*^＠^*)o";
    }
}
